<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pr="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/WEB-INF/facelets/admintemplate.xhtml">
        <!--ui:param name="customcss" value="product.css"/-->

        <ui:param name="title" value="Add Category"/>

        <ui:define name="admincontent">

            <div id="mainProduct">
                
                <h:form prependId="false">
                    <pr:panel id="targetPanel">

                    <pr:tree value="#{categoryBackingBean.root}" var="node" id="tree" dynamic="true"
                             selection="#{categoryBackingBean.selectedNode}"
                             selectionMode="single">
                        <pr:ajax event="select" update="@form" listener="#{categoryBackingBean.nodeListener}"/>  
                        <pr:treeNode>
                            <h:outputText value="#{node}"/>
                            
                        </pr:treeNode>
                    </pr:tree>
                    </pr:panel>
                    <h:inputText id="categoryname" value="#{categoryBackingBean.categoryName}"/>
                    </h:form>
                <h:form>
                    <pr:growl id="growl" showDetail="true"/>
                    <pr:commandButton value="Remove" update="targetPanel categoryname growl" action="#{categoryBackingBean.removeCategory}"/><br/>
                    <h:outputLabel value="New category name"/>
                    <h:inputText id="newcategoryname" value="#{categoryBackingBean.newCategoryName}">
                        <!--f:validateLength minimum="3"/-->
                    </h:inputText>

                    <pr:commandButton value="Add new category" update="targetPanel newcategoryname growl" action="#{categoryBackingBean.addCategory}"/>
                    <pr:commandButton value="Change name" update="targetPanel newcategoryname categoryname growl" action="#{categoryBackingBean.changeCategory}"/>
                </h:form>

            </div>



        </ui:define>
    </ui:composition>
</html>

